#!/usr/bin/python
# -*- encoding:utf-8 -*-
import json
import sys

import requests



reload(sys)
sys.setdefaultencoding('utf-8')  # @UndefinedVariable

mobile = sys.argv[1]

class Dahan_Call_Voice(object):
    def __init__(self):
        self.account = "dh10521"
        self.password = "d0b14e4e07c32e400c3dd40f2e8e48be"
        self.logfile = "/data/scripts/call_voice_code.log"

    def write_call_log(self,log):
        with open(self.logfile,'a+') as f:
            f.write(log+"\n")

    def call_voice_code(self,mobile):
        data=json.dumps({"account":self.account,
                    "password":self.password,
                     "data":[{
                     "msgid":"49a5f1d78ab84b90a963beac0231213nmkd",
                     "callee":mobile,
                     "text":"500500",
                     "calltype":1,
                     "playmode":0
                }]
            })
        print data
        orderInitReq= requests.post("http://voice.3tong.net/json/voiceSms/SubmitVoc",data=data)
        self.write_call_log(str(orderInitReq.content)+mobile)


imcall=Dahan_Call_Voice()
mobile_list=mobile.split(",")
for item in mobile_list:
    imcall.call_voice_code(item)
